package net.hymnal.church;

import android.app.Activity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

/**
 * Данный клас загружает гимны из файлов
 */
public class HymnsManager extends SQLiteOpenHelper {
    private static final String TAG = HymnsManager.class.getName();
    private static final String DB_NAME = "hymnal";
    private static final int DB_VERSION = 1;
    private Activity currentActivity;

    public HymnsManager(Activity activity) {
        super(activity, DB_NAME, null, DB_VERSION);
        currentActivity = activity;
    }

    public SingleHymn readHymn(Context context, HymnalType type, int number)  {
        return new SingleHymn(number, "HYMN", null);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    public List<String> search(String searchLineKey) {
        List<String> results = new LinkedList<String>();

        //TODO: поиск строк в БД

        if (results.isEmpty())
            currentActivity.finish();
        return results;
    }
}
